{# Support for Sphinx 1.3+ page_source_suffix, but don't break old builds. #}

{% if page_source_suffix %}
{% set suffix = page_source_suffix %}
{% else %}
{% set suffix = source_suffix %}
{% endif %}

{% if meta is defined and meta is not none %}
{% set check_meta = True %}
{% else %}
{% set check_meta = False %}
{% endif %}

{% if check_meta and 'github_url' in meta %}
{% set display_github = True %}
{% endif %}

{% if check_meta and 'bitbucket_url' in meta %}
{% set display_bitbucket = True %}
{% endif %}

{% if check_meta and 'gitlab_url' in meta %}
{% set display_gitlab = True %}
{% endif %}

<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="pytorch-breadcrumbs">
    {% block breadcrumbs %}
      <li>
        <a href="{{ pathto(master_doc) }}">
            Docs
        </a> &gt;
      </li>

        {% for doc in parents %}
          <li><a href="{{ doc.link|e }}">{{ doc.title }}</a> &gt;</li>
        {% endfor %}
      <li>{{ title }}</li>
    {% endblock %}
    {% block breadcrumbs_aside %}
      <li class="pytorch-breadcrumbs-aside">
        {% if hasdoc(pagename) %}
            {% if github_version in ["main", "master"] %}
            {% set branch_name = "latest" %}
            {% else %}
            {% set branch_name = github_version %}
            {% endif %}
            {% if language == "en" %}
              <a href="/zh_CN/{{ branch_name }}/{{ pagename }}{{ file_suffix }}" class="fa fa-language"> {{ _('以中文阅读') }}</a>
            {% else %}
              <a href="/en/{{ branch_name }}/{{ pagename }}{{ file_suffix }}" class="fa fa-language"> {{ _('Read in English') }}</a>
            {% endif %}
        {% endif %}
      </li>
      {% if hasdoc(pagename) and display_github %}
      <li class="pytorch-breadcrumbs-aside">
        {% if check_meta and 'github_url' in meta %}
          <!-- User defined GitHub URL -->
          <a href="{{ meta['github_url'] }}" class="fa fa-github"> {{ _('Edit on GitHub') }}</a>
        {% elif check_meta and 'github_page' in meta %}
          <!-- User defined GitHub URL -->
          <a href="https://{{ github_host|default("github.com") }}/{{ github_user }}/{{ github_repo }}/{{ theme_vcs_pageview_mode|default("blob") }}/{{ github_version }}{{ meta['github_page'] }}" class="fa fa-github"> {{ _('Edit on GitHub') }}</a>
        {% elif default_edit_on_github %}
          <a href="https://{{ github_host|default("github.com") }}/{{ github_user }}/{{ github_repo }}/{{ theme_vcs_pageview_mode|default("blob") }}/{{ github_version }}{{ conf_py_path }}{{ pagename }}{{ suffix }}" class="fa fa-github"> {{ _('Edit on GitHub') }}</a>
        {% endif %}
      </li>
      {% endif %}
    {% endblock %}
  </ul>

  {% if (theme_prev_next_buttons_location == 'top' or theme_prev_next_buttons_location == 'both') and (next or prev) %}
  <div class="rst-breadcrumbs-buttons" role="navigation" aria-label="breadcrumb navigation">
      {% if next %}
        <a href="{{ next.link|e }}" class="btn btn-neutral float-right" title="{{ next.title|striptags|e }}" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
      {% endif %}
      {% if prev %}
        <a href="{{ prev.link|e }}" class="btn btn-neutral" title="{{ prev.title|striptags|e }}" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      {% endif %}
  </div>
  {% endif %}
</div>
